<%--
  Created by IntelliJ IDEA.
  User: Jia_ly
  Date: 2017/3/2
  Time: 17:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path;
    request.setAttribute("basePath", basePath);
    String userName = (String) session.getAttribute("userName");
%>
<%@ include file="../frame/head.jsp" %>
<script src="${basePath}/resources/investigation/js/question/addquestion.js"></script>
<html>
<head>
    <title>template</title>
</head>
<body>
<section>
    <%@include file="../frame/top.jsp" %>
    <section class="boxMain">
        <section class="hbox stretch">
            <%@include file="../frame/aside.jsp" %>
            <div>
                <header>
                    <h3 style="color: #0b6cbc;text-align: center">添加试题</h3>
                </header>
                <hr>
                <div>
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped">
                            <tbody style="text-align:center">
                            <tr class="success">
                                <td><strong>试题名称:</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <textarea id="questionName" type="text" class="form-control" rows="4"></textarea>
                                    </div>
                                </td>
                            </tr>
                            <tr class="active">
                                <td><strong>试题描述:</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <textarea id="questionDesc" type="text" class="form-control" rows="4"></textarea>
                                    </div>
                                </td>
                            </tr>
                            <tr class="success">
                                <td><strong>创建人:</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <input id="creator" type="text" value="<%=userName%>" readonly class="form-control">
                                    </div>
                                </td>
                            </tr>
                            <tr class="active">
                                <td><strong>难易程度:</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <select id="level" class="form-control">
                                            <option value="1">简单</option>
                                            <option value="2">中等</option>
                                            <option value="3">难</option>
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <tr class="success">
                                <td><strong>考试科目:</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <select id="kindId" class="form-control" onchange="kindChange(this)">
                                            <option value="0">新增</option>
                                        </select>
                                        <br>
                                        <input id="kindname" type="text" class="form-control" placeholder="科目名称">
                                        <br>
                                        <input id="kinddesc" type="text" class="form-control" placeholder="科目描述">
                                    </div>
                                </td>
                            </tr>
                            <tr class="active">
                                <td>
                                    <strong>试题类型:
                                    </strong><br>
                                    （主观类试<br>题可按自<br>己要求填写<br>试题类型）
                                </td>
                                <td>
                                    <div class="col-xs-8">
                                        <select id="q_type" class="form-control" onchange="isselect(this)">
                                        </select>
                                        <br>
                                        <input id="typename" type="text" class="form-control" placeholder="类型名称" style="display: none">
                                    </div>
                                </td>
                            </tr>
                            <tr class="success">
                                <td><strong>知识点：</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <select id="pointId" onchange="pointchange(this)" class="form-control">
                                            <option value="0">新增</option>
                                        </select>
                                        <br>
                                        <input id="pointname" type="text" class="form-control" placeholder="知识点名称">
                                        <br>
                                        <input id="pointdesc" type="text" class="form-control" placeholder="知识点描述">
                                    </div>
                                </td>
                            </tr>
                            <tr id="choice" class="active">
                                <td><strong>答案选项:</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <%--填空题答案--%>
                                        <div id="answer1">
                                            A:<input id="answerA" type="text" class="form-control">
                                            B:<input id="answerB" type="text" class="form-control">
                                            C:<input id="answerC" type="text" class="form-control">
                                            D:<input id="answerD" type="text" class="form-control">
                                        </div>
                                        <%--判断答案--%>
                                        <div id="answer2" style="display: none">
                                            T:<input id="trueanswer" type="text" class="form-control">
                                            F:<input id="falseanswer" type="text" class="form-control">
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr class="success">
                                <td><strong>正确答案:</strong></td>
                                <td>
                                    <div class="col-xs-8">
                                        <%--选择题--%>
                                        <select id="select1" class="form-control">
                                            <option value="0">A</option>
                                            <option value="1">B</option>
                                            <option value="1">C</option>
                                            <option value="1">D</option>
                                        </select>
                                            <%--判断题--%>
                                        <select id="select2" class="form-control" style="display: none">
                                            <option value="0">T</option>
                                            <option value="1">F</option>
                                        </select>
                                        <%--填空题--%>
                                        <input id="select3" type="text" class="form-control" style="display: none"/>
                                        <%--主观题--%>
                                        <%--<textarea id="select4" type="text" rows="4" class="form-control" style="display: none"></textarea>--%>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div align="center">
                    <button id="submit" onclick="submit()" class="btn btn-s-md btn-primary">提交</button>
                    <button id="cancel" onclick="history.go(-1)" class="btn btn-s-md btn-info">取消</button>
                </div>
            </div>
        </section>
    </section>
</section>
</body>
</html>
<script>
    //试题类型相关显示隐藏
    function isselect(selectPress) {
        var selectValue = selectPress.options[selectPress.selectedIndex].value;
       /* if(selectValue == '0'){
            //    document.getElementById("q_type").style.display="none";
            document.getElementById("typename").style.display="";
            document.getElementById("answer1").style.display="none";
            document.getElementById("answer2").style.display="none";
            document.getElementById("select1").style.display="none";
            document.getElementById("select2").style.display="none";
            document.getElementById("select3").style.display="none";
        }*/
        // 1 表示判断题
        if(selectValue == '1'){
            document.getElementById("q_type").style.display="";
            document.getElementById("typename").style.display="none";
            document.getElementById("answer1").style.display="";
            document.getElementById("select1").style.display="";
            document.getElementById("answer2").style.display="none";
            document.getElementById("select2").style.display="none";
            document.getElementById("select3").style.display="none";
        //    document.getElementById("select4").style.display="none";
        //    document.getElementById("choice").style.display="";
        }
        // 2 表示选择题
        if(selectValue == '2'){
            document.getElementById("q_type").style.display="";
            document.getElementById("typename").style.display="none";
            document.getElementById("answer2").style.display="";
            document.getElementById("select2").style.display="";
            document.getElementById("answer1").style.display="none";
            document.getElementById("select1").style.display="none";
            document.getElementById("select3").style.display="none";
         //   document.getElementById("select4").style.display="none";
         //   document.getElementById("choice").style.display="";
        }
        // 3 表示填空题
        if(selectValue == '3'){
            document.getElementById("q_type").style.display="";
            document.getElementById("typename").style.display="none";
            document.getElementById("select3").style.display="";
            document.getElementById("answer2").style.display="none";
            document.getElementById("select2").style.display="none";
            document.getElementById("answer1").style.display="none";
            document.getElementById("select1").style.display="none";
         //   document.getElementById("select4").style.display="none";
        //    document.getElementById("choice").style.display="none";
        }
        // 4 表示主观题
        if(selectValue == '4'){
            document.getElementById("q_type").style.display="";
            document.getElementById("typename").style.display="";
        //    document.getElementById("select4").style.display="";
            document.getElementById("answer2").style.display="none";
            document.getElementById("select2").style.display="none";
            document.getElementById("answer1").style.display="none";
            document.getElementById("select1").style.display="none";
            document.getElementById("select3").style.display="none";
        //    document.getElementById("choice").style.display="none";
        }
        if((selectValue != '4') && (selectValue != '3') && (selectValue != '2') && (selectValue != '1')) {
            document.getElementById("q_type").style.display="";
            document.getElementById("typename").style.display="none";
            document.getElementById("answer2").style.display="none";
            document.getElementById("select2").style.display="none";
            document.getElementById("answer1").style.display="none";
            document.getElementById("select1").style.display="none";
            document.getElementById("select3").style.display="none";
        }
    }

    //科目相关显示隐藏
    function kindChange(addinput){
        var kind = addinput.options[addinput.selectedIndex].value;
        // 0 表示添加新的科目
        if(kind == '0'){
         //   document.getElementById("kindId").style.display="none";
            document.getElementById("kindname").style.display="";
            document.getElementById("kinddesc").style.display="";
            document.getElementById("answer1").style.display="";
            document.getElementById("answer2").style.display="none";
            document.getElementById("select1").style.display="";
            document.getElementById("select2").style.display="none";
            document.getElementById("select3").style.display="none";
        }
        else {
            document.getElementById("kindId").style.display="";
            document.getElementById("kindname").style.display="none";
            document.getElementById("kinddesc").style.display="none";
            document.getElementById("answer1").style.display="";
            document.getElementById("answer2").style.display="none";
        }
    }

    //知识点相关显示隐藏
    function pointchange(addinput){
        var add = addinput.options[addinput.selectedIndex].value;
        // 0 表示添加新的知识点
        if(add == '0'){
        //    document.getElementById("pointId").style.display="none";
            document.getElementById("pointname").style.display="";
            document.getElementById("pointdesc").style.display="";
        }
        else {
            document.getElementById("pointId").style.display="";
            document.getElementById("pointname").style.display="none";
            document.getElementById("pointdesc").style.display="none";
        }
    }
</script>
